package com.ruge.sms.controller;

import com.ruge.core.enums.SmsEnum;
import com.ruge.core.response.Response;
import com.ruge.sms.service.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: ruge-cloud
 * @description:
 * @author: ruge.wu
 * @create: 2022-01-09 00:17
 **/
@RestController
@Api(tags = "短信相关接口")
@RequestMapping("internal/sms")
public class SmsInternalController {

    @Resource
    private SmsService smsService;

    @GetMapping("sendSms")
    @ApiOperation(value = "发送短信")
    public Response SendSms(
            @ApiParam(name = "smsEnum", value = "发送的验证码类型", required = true) @RequestParam("smsEnum") SmsEnum smsEnum,
            @ApiParam(name = "mobiles", value = "手机号码", required = true) @RequestParam("mobiles") List<String> mobiles,
            @ApiParam(name = "params", value = "参数", required = true) @RequestParam("params") String[] params
    ) {
        return smsService.sendSms(smsEnum, mobiles, params);
    }

    @GetMapping("validSms")
    @ApiOperation(value = "校验短信")
    public Response validSms(
            @ApiParam(name = "smsEnum", value = "发送的验证码类型", required = true) @RequestParam("smsEnum") SmsEnum smsEnum,
            @ApiParam(name = "mobiles", value = "手机号码", required = true) @RequestParam("mobiles") List<String> mobiles,
            @ApiParam(name = "params", value = "参数", required = true) @RequestParam("params") String[] params
    ) {
        return smsService.validSms(smsEnum, mobiles, params);
    }

}
